package com.vader.uid.generator.controller;

import com.vader.common.entity.CommonResponse;
import com.vader.uid.generator.UidGenerator;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;

/**
 * @author Vader
 * @date 2021/10/6
 **/
@RestController
@RequestMapping("/distributeId")
public class DistributeController {

    @Resource(name = "cachedUidGenerator")
    private UidGenerator uidGenerator;

    @GetMapping("/getId")
    public CommonResponse<Long> getId() {
        long uid = uidGenerator.getUID();
        return CommonResponse.success(uid);
    }
}
